import json

from flask import render_template, request

from . import front
from Search.getdata import *


@front.route('/snapshot')
def _snapshot():
    if url := request.args.get('url'):
        title = information.loc[url]['title']
        with open(rf'./data/data_pages/{title}.html',encoding='utf-8') as f:
            snapshot = f.read()
        return render_template(r'snapshot.html', snapshot=snapshot)# 返回快照
    else:
        return "invalid arguments!"